
function Animal(eats,hasLegs,isVegetarian){
    //this = {};
    this.eats = eats;
    this.hasLegs = hasLegs;
    this.isVegetarian = isVegetarian;
    //return this;
}
//Animal.prototype = {};

//new -- instance
var herbivorousAnimal = new Animal(true,true,true);
//HerbivorousAnimal.eats

//HerbivorousAnimal
//{
//eats: true,
//hasLegs: true,
//isVegetarian: true
//}
function Rabbit(name){
    //{
    this.name = name;
}

Rabbit.prototype = herbivorousAnimal;

var rabbit = new Rabbit('John');

//rabbit.name -> John
rabbit.isVegetarian ;//true
rabbit.eats ;//key


function Deer(name){
    this.name = name;
    this.horns = true;

}
//{

//}
//new Object();//
var deer = new Deer('Jim')
//instanceof
//console.log(herbivorousAnimal instanceof Animal);//true
//console.log(rabbit instanceof Animal);//true
//console.log(rabbit instanceof Rabbit);// true
//console.log(herbivorousAnimal instanceof Rabbit);//false
//console.log(deer instanceof Animal);//false
//console.log(rabbit instanceof Object);//true
//

function Vehicle(motor){
    this.motor = motor;
}

var vehicle = new Vehicle('true');

function Car(engine){
    this.engine = engine;
    this.motor = "supermotor";
}

Car.prototype = vehicle;

var car = new Car('v4');
//car -> engine, motor
function Honda(model,year){
    this.model = model;
    this.year = year;
    this.motor = "ultramotor";
}

Honda.prototype = car;
var honda = new Honda('Accord','2015');
//honda //model, year, engine, motor
//honda.motor;//ultramotor
//honda.engine;
console.log(honda instanceof Car); // true
console.log(car instanceof Honda); //false
console.log(car instanceof Vehicle);//true
console.log(honda instanceof Vehicle);//true
console.log(vehicle instanceof Honda);//false
//prototypal chain

honda.motor ;//Honda
//Car
//Honda --> Car/  --> Vehicle -->
//

//honda.model =

honda.ceo //undefined

for(var oneproperty in honda){
    //key -- motor

    console.log('key is ' + oneproperty + ' and value by [] is  '+
        honda[oneproperty] + ' and value by . is '+ honda.oneproperty);
}
honda['model'];
honda.oneproperty  // undefined
//
//honda.key;//honda[key];// "ultramotor";
//honda.key ;//
//honda[key];
var propName = 'age';
var person =  {
    name : "Madhu",
    age : 33,
    propName: "I am prop Name inside person"
}

person[propName];//33
person['age'];//33
person['propName'];//I am prop Name inside person

// prototypal inheritance
// closure
// object.create

//timer
//setTimeout and setInterval
//anonymous function

function Print(){
    console.log('print this set time out');
}
function PrintInterval(){
    console.log('this is set Interval')
}
setTimeout(Print,200);
setInterval(PrintInterval,200);

